home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 019a / amac40.zip / SRQ.QM < prev    next >
Text File  |  1991-05-06  |  7KB  |  122 lines

  1. *                                SRQ.QM              May 6, 1991
  2. * --------------------------------------------------------------------
  3. * @(4) Search/replace from command line, quit each file after rplcmnt.
  4. * --------------------------------------------------------------------
  5. *
  6. * Often the total size of files needing a "replacement" will exceed the
  7. * available memory when using SR.BAT and the startup macro @0. Macro @4
  8. * in SRQ.QM is simply a modification of @0 by replacing savefile with
  9. * file, so each file is quit after replacement.
  10. *
  11. * This macro must be the first macro in the file because it is used as
  12. * the startup macro with SRQ.BAT. It cannot be run from command line!
  13. *
  14. @4      MacroBegin
  15.         altwordset                      * For all file names
  16. * ------------------ display "No found text" message -----------------*
  17.         cursordown cursorup             * Test if any search text found
  18.         jtrue START:                    * If found, move on
  19.  MESSAGE:                               *
  20.         "No found text "                * If not found, display this
  21.         jump END:                       * End macro if no found text
  22.  START:                                 *
  23. * ---------------------------- load files ----------------------------*
  24.         endfile                         * Get to end of file
  25.  LOADAGAIN:                             *
  26.         unmarkblock                     * Unmark last file name
  27.         find #42 "Fi" return "B"  return* Find file name
  28.  jfalse  MESSAGE:                       * No find ?, show message, end
  29.         wordright                       * Move to space
  30.         wordright                       * Move to file name
  31.         markcolumn                      * Mark it
  32.         endline                         * Get all name in block
  33.         copy                            * Copy file name to scrap
  34.         EditFile                        * Get ready to load
  35.         CurrentFilename " "             * To force return *here*
  36.         Paste Return                    * Paste file name & do it!
  37.         cursorup                        * Go to next line
  38.  jfalse ENDLOAD:                        * No more filenames? Done load
  39.  jump LOADAGAIN:                        * Check again
  40.  ENDLOAD:                               *
  41.         quit                            * Quit c:\! from ring so no rplc
  42. * -------------------- get search text to scratch --------------------*
  43.         editfile "c:\$" return          * Load set output file
  44.         find  "S~~" return return       * Find S~~                     |2.7
  45.         find "=" return return          * Move to =                    |
  46.         cursorright                     * Move first character         |
  47.         markcharacter                   * Mark it                      |
  48.         endline                         * Move to end of text          |
  49.         storescrbuff "S~~" return       * Store SEARCH text to scratch |
  50. * ------------------- get replace text to scratch -------------------*
  51.         unmarkblock                     * Get ready
  52.         begfile                         * Get to top
  53.         find  "R~~" return return       * Find R~~                     |2.7
  54.         find "=" return return          * Move to =                    |
  55.         cursorright                     * Move first character         |
  56.         markcharacter                   * Mark it                      |
  57.         endline                         * Move to end of text          |
  58.         storescrbuff "R~~" return       * Store REPLACE text to scratch|
  59.         killfile                        * Kill c:\$ for next time
  60.         quit                            * Remove c:\$ from ring
  61. * --------------- get search/replace text from scratch ---------------*
  62.         Editfile "NUL" Return           * Insert -or- GoTo NUL File
  63.         getscrbuff "S~~" return cut     * Cut search text from scratch |2.7
  64.         Find paste Return escape        * Initialize find prompt
  65.         getscrbuff "R~~" return cut     * Cut replace text from scratch|2.7
  66.         FindReplace return              * Begin replacement
  67.         paste return                    * paste REPLACEMENT text
  68.        "GIN"                            * Replace options
  69. *       pause                          ** Add this to pause for options
  70.         return                          * MUST include "GN"
  71. * ------------------ load files, do search/replace ------------------*
  72.         Begline Cursorright      * Put cursor in Col. 2 of NUL File
  73.         LOOP:                    * Main test loop
  74.             Nextfile             * Move to next files in Ring
  75.             Cursorleft           * Move cursor left (need for NUL test)
  76.             Jfalse DOIT:         * If couldn't move to left, it's not
  77.                                  * the NUL File AND cursor position
  78.                                  * has not changed -- GO with the
  79.                                  * FindReplace
  80.                                  *ELSE
  81.                                  * Check to see if in the NUL File
  82.             Cursorleft           * Move cursor left for NUL Test
  83.             Jfalse ENDLOOP:      * If couldn't move left -- We
  84.                                  * ARE in the NUL File and Need
  85.                                  * to ENDLOOP
  86.                                  *ELSE
  87.             Cursorright          * Move back to Col. 2 in NUL File
  88.         DOIT:                    * FindReplace Loop
  89.             BegFile              * Move up in case cursor is below find
  90.             Repeatfind           * Do the FindReplace
  91.             Jtrue SAVE:          * If CHANGES are made -- SAVE the File
  92.             Quit                 * If NO CHANGES are made -- QUIT the
  93.                                  * File
  94.             Jump LOOP:           * Return to the Main Loop
  95.         SAVE:                    * Routine to Save a File with Changes
  96.             File                 * Save and quit this file after rplcmnmt
  97.             Jump LOOP:           * Return to Main Loop
  98.         ENDLOOP:                 * Loop is DONE
  99.             Quit                 * Quit the NUL File
  100.  END:                            *
  101. * ------------------------------ reset ------------------------------*
  102.         defaultwordset           * Set default
  103. *
  104. * 153 bytes Tue  10-02-1990  18:50:33
  105. * 200 bytes Thu  04-25-1991  12:02:23 added "No found text" message
  106. *                                     added "GIN" auto replace option
  107. *                                     changed file "_" to NUL", faster
  108. *                                     changed "c:" to "c:\"
  109. * 208 bytes Tue  04-30-1991  22:16:22 changed search and replace to scrap
  110.  
  111. * (F4)
  112. f4      RepeatFind
  113.  
  114.  
  115. * (F5)
  116. f5      PrevFile
  117.  
  118. * (F6)
  119. f6      NextFile
  120.  
  121. * Tom Hogshead
  122.